<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="../../../static/layui/css/layui.css" />
    <link rel="stylesheet" href="../../../static/css/bootstrap-theme.min.css" />
    <script src="../../../static/js/jquery-3.3.1.min.js"></script>

</head>
<body>
<div class="layui-card">
    <div class="layui-card-header">
        <h2>教师添加课程</h2>
    </div>
    <form class="layui-form" id="addCourseForm">

        <div class="layui-form-item">
            <label class="layui-form-label">课程名称</label>
            <div class="layui-input-inline">
                <input type="text" name="courseName" required lay-verify="required"  placeholder="请输入课程名称"  autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">课程类别</label>
            <div class="layui-input-inline">
           <select name="courseType">
               <option value="专业必修课">专业必修课</option>
               <option value="专业选修课">专业选修课</option>
               <option value="公共必修课">公共必修课</option>
               <option value="公共选修课">公共选修课</option>
           </select>
            </div>

        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">课程学分</label>
            <div class="layui-input-inline">
                <input type="number" name="courseCredit" required lay-verify="required"  placeholder="请输入课程学分"  autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">课程学时</label>
            <div class="layui-input-inline">
                <input type="number" name="courseHour" required lay-verify="required"  placeholder="请输入课程学时"  autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">容纳人数</label>
            <div class="layui-input-inline">
                <input type="number" name="courseVolume" required lay-verify="required"  placeholder="课程容纳人数"  autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" style="display: none">
            <label class="layui-form-label">教师ID</label>
            <div class="layui-input-inline">
                <input type="text" name="teacherId" required lay-verify="required" value="${sessionScope.teacher.teacherId}"  placeholder="教师ID"  autocomplete="off"
                       class="layui-input">
            </div>
        </div>


        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">课程描述</label>
            <div class="layui-input-block">
                <textarea name="courseDesc" placeholder="课程描述"  class="layui-textarea"></textarea>
            </div>
        </div>




        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn addCourse" lay-submit lay-filter="addCourse">立即提交</button>
            </div>
        </div>

    </form>
</div>
<script src="../../../static/layui/layui.all.js"></script>
<script>
    //Demo

    layui.use('form', function() {
        var form = layui.form;
        var layer = layui.layer;


            $('.addCourse').click(function(){
                $.post(
                    "${pageContext.request.contextPath}/teacherReleaseCourse",
                    $('#addCourseForm').serialize(),
                    function (data) {
                        if (data == 0) {
                            layer.msg("添加失败",{icon:"5"});
                        }else if(data>0){
                            layer.msg("添加成功！ 记得重新刷新加载数据哦~",{icon:"6"});
                            parent.location.reload();

                        }
                    }
                )

                return false;
            });

    });
</script>
<script>

</script>

</body>
</html>
